package com.yy.wga.admin.service.controller;

import com.yy.wga.mp.common.aop.NotLogin;
import com.yy.wga.mp.module.admin.request.AdminUserIoginRequest;
import com.yy.wga.mp.module.admin.response.AdminUserInfoResponse;
import com.yy.wga.mp.module.admin.service.AdminUserService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 运营后台/用户登录接口
 *
 * @author guochao
 * @since 2022-11-01 19:08:37
 */
@RestController
@RequestMapping("/admin")
public class AdminUserLoginController {
    /**
     * 服务对象
     */
    @Resource
    private AdminUserService adminUserService;

    @NotLogin
    @PostMapping(value = "/login")
    public Result<AdminUserInfoResponse> login(@RequestBody @Valid AdminUserIoginRequest request) {
        return Result.success(adminUserService.login(request));
    }

    @PostMapping(value = "/logout")
    public Result<Boolean> logout() {
        adminUserService.logout();
        return Result.success(Boolean.TRUE);
    }
}
